    //
    document.onkeydown = function (ev) {
        if (ev && ev.keyCode == 13){
            send();
            clear();
        }
    }
    var socket;
    if (window.WebSocket) {
        socket = new WebSocket("ws://localhost:8899");
        // socket = new WebSocket("ws://127.0.0.1:9999");
        // socket = new WebSocket("ws://192.168.43.186:9999");
        socket.onmessage = function (ev) {
            atalkAppendIn("接收:"+socket.channel + ":" + ev.data)
        };
        socket.onopen = function () {
            btalkAppendIn("连接已建立");
        }
        socket.onclose = function () {
            btalkAppendIn("连接关闭");
        };
    }else {
        alert("浏览器不支持");
    }
    function send(){
        var message = document.getElementById("talkwords");
        if (!window.WebSocket){
            return
        }
        if (socket.readyState === WebSocket.OPEN){
            var date = new Date();
            var data = {
                msgId:50,
                msgType:1000,
                msg:message.value,
                uId:1
            }
            var jsonData = JSON.stringify(data);

            socket.send(jsonData);
            socket.send("data" + data);
            console.log("jsonData" + jsonData);
            btalkAppendIn("发送:" + jsonData);
            clear();
        } else {
            alert("WebSocket 建立失败");
        }
    }

    function atalkAppendIn(text) {
        var append = document.getElementById("words");
        console.log(text);
        append.innerHTML+= '<div class="atalk"><span>'+ text +'</span></div>';
    }

    function btalkAppendIn(text) {
        var append = document.getElementById("words");
        console.log(text);
        append.innerHTML+= '<div class="btalk"><span>'+ text +'</span></div>';
    }
    function clear () {
        var elementById = document.getElementById("talkwords");
        elementById.value = "";
    }
